package com.sk.cardeal.adapter;

import android.graphics.Color;
import android.provider.MediaStore;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.luck.picture.lib.entity.LocalMedia;
import com.sk.cardeal.R;

import java.util.List;

/**
 * Created by sk on 2018/1/10.
 */

public class PicAdapter extends BaseQuickAdapter<LocalMedia,BaseViewHolder> {

    public PicAdapter(int layoutResId, @Nullable List<LocalMedia> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, LocalMedia item) {
        if (helper.getAdapterPosition() == mData.size()-1) {
            helper.getView(R.id.item_bg).setBackgroundColor(Color.WHITE);
            Glide.with(mContext).load(R.mipmap.add_picture).into((ImageView) helper.getView(R.id.item_bg));
        } else {
            if (item.isCompressed()) {
                Glide.with(mContext).load(item.getCompressPath()).into((ImageView) helper.getView(R.id.item_bg));
            } else {
                Glide.with(mContext).load(item.getPath()).into((ImageView) helper.getView(R.id.item_bg));
            }

        }
    }
}
